﻿using EMall.ProductService.ProductSkus;
using EMall.Query;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace EMall.ProductService.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    [Authorize]
    public class ProductSkuController : ControllerBase, IProductSkuAppService
    {
        private readonly IProductSkuAppService _productSkuAppService;
        public ProductSkuController(IProductSkuAppService productSkuAppService)
        {
            _productSkuAppService = productSkuAppService;
        }
        [HttpPost]
        public async Task AddStockAsync(AddProductSkuStock input)
        {
            await _productSkuAppService.AddStockAsync(input);
        }
        [HttpPost]
        public async Task CreateAsync(CreateProductSkuDto input)
        {
            await _productSkuAppService.CreateAsync(input);
        }
        [HttpGet]
        public async Task<ProductSkuDto> GetAsync(int id)
        {
            return await _productSkuAppService.GetAsync(id);
        }
        [HttpGet]
        public async Task<IPagedList<ProductSkuListDto>> GetPagedListAsync([FromQuery] GetProductSkuPagedListQueryDto input)
        {
            return await _productSkuAppService.GetPagedListAsync(input);
        }
        [HttpPost]
        public async Task RemoveStockAsync(RemoveProductSkuStock input)
        {
            await _productSkuAppService.RemoveStockAsync(input);
        }
        [HttpPost]
        public async Task UpdateAsync(UpdateProductSkuDto input)
        {
            await _productSkuAppService.UpdateAsync(input);
        }
    }
}
